import numpy as np
import pandas as pd
from sklearn.metrics import roc_auc_score, log_loss
prediction_app_DeepFM = pd.read_csv("./result/prediction_app_DeepFM.csv")
prediction_site_DeepFM = pd.read_csv("./result/prediction_site_DeepFM.csv")
prediction_DeepFM = pd.concat([prediction_app_DeepFM, prediction_site_DeepFM],ignore_index=True)

prediction_app_DIN = pd.read_csv("./result/prediction_app_DIN.csv")
prediction_site_DIN = pd.read_csv("./result/prediction_site_DIN.csv")
prediction_DIN = pd.concat([prediction_app_DIN, prediction_site_DIN],ignore_index=True)

prediction_app_DIEN = pd.read_csv("./result/prediction_app_DIEN.csv")
prediction_site_DIEN = pd.read_csv("./result/prediction_site_DIEN.csv")
prediction_DIEN = pd.concat([prediction_app_DIEN, prediction_site_DIEN],ignore_index=True)


test_app = pd.read_csv("./data/new_valid_app.csv",usecols=['id','click'])
test_site = pd.read_csv("./data/new_valid_site.csv",usecols=['id','click'])
test_data = pd.concat([test_app,test_site],ignore_index=True)

print("========== DeepFM Result =============")
print("AUC: {:.4f}".format(roc_auc_score(test_data['click'], prediction_DeepFM['click'])))
print("Log Loss : {:.4f}".format(log_loss(test_data['click'], prediction_DeepFM['click'])))

print("========== DIN Result =============")
print("AUC: {:.4f}".format(roc_auc_score(test_data['click'], prediction_DIN['click'])))
print("Log Loss : {:.4f}".format(log_loss(test_data['click'], prediction_DIN['click'])))

print("========== DIEN Result =============")
print("AUC: {:.4f}".format(roc_auc_score(test_data['click'], prediction_DIEN['click'])))
print("Log Loss : {:.4f}".format(log_loss(test_data['click'], prediction_DIEN['click'])))

print("========== Ensemble Result ===========")
merge_prediction = 0.25 * prediction_DeepFM['click'] + 0.25 * prediction_app_DIN['click'] + 0.5 * prediction_app_DIEN['click']
print("AUC: {:.4f}".format(roc_auc_score(test_data['click'], (prediction_DeepFM['click'] + prediction_DIN['click']) / 2)))
print("Log Loss : {:.4f}".format(log_loss(test_data['click'], (prediction_DeepFM['click'] + prediction_DIN['click']) / 2)))
